Skip to content

Spread keyword args to support Ruby 3 - #85

Merged
mrcasals merged 4 commits into
codegram:masterfrom
PlayerData:ruby-3
Feb 3, 2021
Merged

mrcasals merged 4 commits into
codegram:masterfrom
PlayerData:ruby-3

Conversation

@ball-hayden

@ball-hayden ball-hayden commented Dec 28, 2020 •

Copy link
Copy Markdown
Contributor

✍️ Description

As of Rails 6.1, ActiveRecord::Errors.add spreads keyword arguments rather than accepting an options hash (https://api.rubyonrails.org/v6.1.0/classes/ActiveModel/Errors.html#method-i-add).

In Ruby 3, there is no implicit cast between a last hash argument and explicit keyword arguments, causing argument errors:

     ArgumentError:
       wrong number of arguments (given 3, expected 1..2)
     # ./vendor/bundle/ruby/3.0.0/gems/activemodel-6.1.0.rc2/lib/active_model/errors.rb:404:in `add'
     # ./vendor/bundle/ruby/3.0.0/gems/date_validator-0.10.0/lib/active_model/validations/date_validator.rb:97:in `block in validate_each'

✅ QA

Before requesting a review, please make sure that:

  • Preview is working on Netlify, Heroku or similar.
  • Manually check that it's working.
  • Add documentation and tests if needed.

@ball-hayden

ball-hayden commented Dec 28, 2020 •

Copy link
Copy Markdown
Contributor Author

https://github.com/actions/setup-ruby doesn't support Ruby 3 yet, so I can't add Ruby 3 to CI.

@ball-hayden

ball-hayden commented Dec 28, 2020 •

Copy link
Copy Markdown
Contributor Author

The test failure (2.7, 5.2) appears to be a flake, but I can't see a way to re-run the check.

I can reproduce the flake with the specified seed (it passes with other seeds), but I can't trace the cause 😦

@ball-hayden
ball-hayden marked this pull request as ready for review December 28, 2020 17:13
@mrcasals

Copy link
Copy Markdown
Contributor

Hi @ball-hayden! We're using https://github.com/ruby/setup-ruby instead of https://github.com/actions/setup-ruby as it supports more versions (including Ruby 3.0), so it should be fine! Can you try adding the version?

Comment thread .github/workflows/ci.yml
ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7]
activemodel: [3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0]
activemodel: [3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0, 6.1]
include:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've chosen include here rather than explicitly excluding ActiveModel 3.2 - 5.2 for Ruby 3.0

Comment thread Gemfile
gem 'activemodel', active_model_opts

platforms :rbx do
gem 'rubysl', '~> 2.0'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through history, it looks like this was added to test against Rubinius at some stage in the past?

@ball-hayden

ball-hayden commented Dec 29, 2020 •

Copy link
Copy Markdown
Contributor Author

@mrcasals Thanks for your review.

That's Ruby 3.0 running in CI, and a good job too - it caught a few other places 🙂. All updated now.

@ball-hayden

Copy link
Copy Markdown
Contributor Author

@mrcasals would you be able to take another look at this, please?

@thibaudgg

Copy link
Copy Markdown

It would be great to see that patch merged and a new release of the gem. I'm running it on production, no issues so far. 👍🏻

@mrcasals

Copy link
Copy Markdown
Contributor

Hi @ball-hayden I'm seeing some CI errors 😞 any idea what's going on?

@ball-hayden

Copy link
Copy Markdown
Contributor Author

The error there looks to be an intermittent flake - I can reproduce on master by running e.g.

TESTOPTS="--seed=7220" ACTIVE_MODEL_VERSION=5.2 bundle exec rake test
# or
TESTOPTS="--seed=50616" ACTIVE_MODEL_VERSION=5.2 bundle exec rake test

I did have a quick look to see if I could trace it, but I didn't get that far. I'd guess there's state that's leaking between tests?

@mrcasals

Copy link
Copy Markdown
Contributor

I'll try rerunning the test suite!

@n-rodriguez

Copy link
Copy Markdown

Hi there! any news?

@ball-hayden

Copy link
Copy Markdown
Contributor Author

I'm afraid I haven't had a look into the test issues.

They are reproducible as described above - if you can find what's going on that would help move this PR forwards 🙂

@ball-hayden ball-hayden mentioned this pull request Jan 30, 2021
1 of 3 tasks
@ball-hayden

Copy link
Copy Markdown
Contributor Author

I'm hopeful #86 will fix the flakes we're seeing in CI.
If that is mergeable I will rebase this branch and, hopefully, we'll be good to go with this PR ✅.

@mrcasals

mrcasals commented Feb 1, 2021

Copy link
Copy Markdown
Contributor

Hi @ball-hayden! I merged #86, can you rebase this one? 😄

@ball-hayden

ball-hayden commented Feb 1, 2021 •

Copy link
Copy Markdown
Contributor Author

🎉

@ball-hayden

Copy link
Copy Markdown
Contributor Author

@mrcasals would you mind having another look now this has passed CI?

@mrcasals

mrcasals commented Feb 3, 2021

Copy link
Copy Markdown
Contributor

Thanks, @ball-hayden and sorry for the delay on this!

@mrcasals
mrcasals merged commit a9a4637 into codegram:master Feb 3, 2021
@dwightwatson

Copy link
Copy Markdown

Any chance of getting a new versioned release with this fix?

@ball-hayden
ball-hayden deleted the ruby-3 branch February 4, 2021 08:47
@ball-hayden

Copy link
Copy Markdown
Contributor Author

Sorry to bump @mrcasals, but is there any chance of a release please?

@ccdredzik

Copy link
Copy Markdown

@mrcasals bump for interest

@mrcasals

Copy link
Copy Markdown
Contributor

@dwightwatson @ball-hayden @ccdredzik new version just released! Check 0.11.0:

https://rubygems.org/gems/date_validator

Thanks for your patience!

@be-ragheb be-ragheb mentioned this pull request Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants